@Inject('$http')
class DeviceService {
  save(device) {
    return this.$http.post('/api/v1/device/add', device);
  }

  get(id) {
    return this.$http({
      url: '/api/v1/device/get',
      method: 'GET',
      params: { id },
    });
  }

  saveInTime(device) {
    return this.$http.post('/api/v1/deviceInOut/in/add', device);
  }

  saveOutTime(device) {
    return this.$http.post('/api/v1/deviceInOut/out/add', device);
  }

  query(device) {
    return this.$http.post('/api/v1/device/query', device);
  }

  // /**
  //  * @param  {Array<String>}
  //  * @return {[type]}
  //  */
  delete(ids) {
    return this.$http.post('/api/v1/device/delete', ids);
  }

  update(device) {
    return this.$http.post('/api/v1/device/update', device);
  }

  // 检测记录列表
  queryCheck(param) {
    return this.$http.post('/api/v1/deviceCheck/query', param);
  }

  saveCheck(param) {
    return this.$http.post('/api/v1/deviceCheck/add', param);
  }

  deleteCheck(ids) {
    return this.$http.post('/api/v1/deviceCheck/delete', ids);
  }

  updateCheck(device) {
    return this.$http.post('/api/v1/deviceCheck/update', device);
  }

  getCheck(id) {
    return this.$http({
      url: '/api/v1/deviceCheck/get',
      method: 'GET',
      params: id,
    });
  }

  // 维保记录列表
  queryMaintain(param) {
    return this.$http.post('/api/v1/deviceMaintain/query', param);
  }

  saveMaintain(param) {
    return this.$http.post('/api/v1/deviceMaintain/add', param);
  }

  deleteMaintain(ids) {
    return this.$http.post('/api/v1/deviceMaintain/delete', ids);
  }

  updateMaintain(device) {
    return this.$http.post('/api/v1/deviceMaintain/update', device);
  }

  getMaintain(id) {
    return this.$http({
      url: '/api/v1/deviceMaintain/get',
      method: 'GET',
      params: id,
    });
  }

  // 进出场记录
  queryInOut(id) {
    return this.$http.post('/api/v1/deviceInOut/query', id);
  }

  // 设备资料
  queryDocument(param) {
    return this.$http.post('/api/v1/device/document/query', param);
  }

  deleteDocument(ids) {
    return this.$http.post('/api/v1/device/document/delete', ids);
  }

  updateDocument(param) {
    return this.$http.patch('/api/v1/device/document/update', param);
  }

  saveDocument(param) {
    return this.$http.post('/api/v1/device/document/add', param);
  }

  getDocument(id) {
    return this.$http({
      url: '/api/v1/device/document/get',
      method: 'GET',
      params: id,
    });
  }
}

export default DeviceService;
